/**
 * Created by Eoly on 2016/12/31.
 */
function Point(x, y) {
    this.x = x;
    this.y = y;
}

Point.prototype = {
    getOtherPointFromDistanceAndDeg: function (distance, deg) {
        var radian = Math.PI / 180 * deg;
        var point = new Point();
        point.x = distance * Math.sin(radian) + this.x;
        point.y = this.y - distance * Math.cos(radian);
        return point;
    },
    getDistanceFromAnotherPoint: function (p) {
        return Math.sqrt((this.x - p.x) * (this.x - p.x) + (this.y - p.y) * (this.y - p.y));
    },
    getDegFromAnotherPoint: function (p) {
        //相对于当前点
        var usedPoint = new Point(p.x*1000000 - this.x*1000000, p.y*1000000 - this.y*1000000);
        var radian = Math.atan2(usedPoint.x*1000000, usedPoint.y*1000000);
        var deg = radian * 180 / Math.PI;
        return 180 - deg;
    }
};